package com.example.zuoye1023.view

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.example.rikao1023.base.BaseActivity
import com.example.rikao1023.viewmodel.RegViewModel
import com.example.zuoye1023.R
import com.example.zuoye1023.databinding.ActivityRegBinding

@Route(path = "/reg/RegActivity")
class RegActivity : BaseActivity<ActivityRegBinding,RegViewModel>(R.layout.activity_reg,
    RegViewModel()
) {
    override fun initdata() {

        viewmodel.successreg.observe(this){
            ToastUtils.showShort(it.message)
            if(it.code==200){
                ARouter.getInstance().build("/login/LoginActivity").navigation()
            }
        }
    }

    override fun initview() {

        binding.okReg.setOnClickListener {

            var map=HashMap<String,String>()
            map["username"]=binding.etRegname.text.toString()
            map["password"]=binding.etRegpassword.text.toString()
            map["repassword"]=binding.etRegpassworder.text.toString()
            viewmodel.reg(map)
        }
    }

}